package org.nlp2rdf.navigator.benchmark.cli;

import com.hp.hpl.jena.rdf.model.Resource;
import org.apache.commons.cli.*;
import org.dllearner.core.EvaluatedDescription;
import org.nlp2rdf.navigator.benchmark.BenchmarkContext;
import org.nlp2rdf.navigator.benchmark.BenchmarkUtils;
import org.nlp2rdf.navigator.benchmark.Sample;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;

/**
 * Created by Claus Stadler
 * Date: Oct 22, 2010
 * Time: 7:08:07 PM
 */
public class RunLearner {
    private static final Logger logger = LoggerFactory.getLogger(RunLearner.class);


    private static Options cliOptions = new Options()
        .addOption("f", "sampleFile", true, "File containing a list of positive/negative samples")
        .addOption("c", "configFile", true, "Spring XML config");

    public static void main(String[] args)
            throws Exception
    {
        CommandLine commandLine = CliUtils.getGnuCommandLine(cliOptions, args);
        ApplicationContext context = CliUtils.getApplicationContext(commandLine, commandLine.getOptionValue("c"));

        BenchmarkContext con = new BenchmarkContext(context);
        Sample<Resource> sample = BenchmarkUtils.readSample(commandLine.getOptionValue("f"));

        logger.info("Learning based on sample: " + sample);
        EvaluatedDescription description = con.getLearner().learn(sample);
        logger.info(description.getDescription().toKBSyntaxString());
    }
}
